﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Hsmp.SocietyAdmin.Entity;
using Hsmp.SocietyAdmin.DataAccess;
using Hsmp.SocietyAdmin.IBusinessLogic;

namespace Hsmp.SocietyAdmin.BusinessLogic
{
    public class SocietyRegistrationBus : ISocietyRegistrationBus
    {
        #region  Variable& constant
        #endregion  Variable& constant

        #region Constructor & Destructor
        #endregion Constructor & Destructor

        #region Properties
        #endregion Properties

        #region Public Methods
        #region ISocietyRegistrationBus Members
        public bool RegisterNewSociety(Society SocietyEntity)
        {
            bool IsOperationSuccessful = false;
            try
            {
                SocietyDao lSocietyDao = new SocietyDao();
                IsOperationSuccessful = lSocietyDao.Insert(SocietyEntity);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Print(ex.Message);
                throw ex;
            }
            return IsOperationSuccessful;
        }

        public bool UpdateRegisteredSociety(Society SocietyEntity)
        {
            bool IsOperationSuccessful = false;
            try
            {
                SocietyDao lSocietyDao = new SocietyDao();
                IsOperationSuccessful = lSocietyDao.Update(SocietyEntity);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Print(ex.Message);
                throw ex;
            }
            return IsOperationSuccessful;
        }

        public Society GetSelectedScoietyByID(string SocietyKey)
        {
            try
            {
                SocietyDao lSocietyDao = new SocietyDao();
                Society lSociety;
                lSociety = lSocietyDao.GetByID(SocietyKey);
                if (lSociety == null)
                {
                    return null;
                }
                else
                {
                    return lSociety;
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Print(ex.Message);
                throw ex;
            } 
        }

        public List<Society> GetAllSociety()
        {
            List<Society> lSocietyList = new List<Society>();
            try
            {
                SocietyDao ISocietyDao = new SocietyDao();
                lSocietyList = ISocietyDao.GetAll();
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Print(ex.Message);
                throw ex;
            }
            return lSocietyList;
        }
        
        #endregion
        #endregion Public Methods

        #region Events
        #endregion Events

        #region Private Methods
        #endregion Private Methods
    }
}

